import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner num = new Scanner(System.in);
        int X = num.nextInt();
        int N = num.nextInt();
        int a = (X+N) % 7;
        if(a == 0){
            System.out.println(7);
        }else{
            System.out.println(a);
        }
    }
}
